function f([x, y]: [number, number]): number {
  return x + y
}

function sum({ a, b, c }: { a: number; b: number; c: number }) {
  // todo
}

type ABC = { a: number; b: number; c: number }

function sum01({ a, b, c }: ABC) {
  // todo
}

// rest 参数为数组
function joinNumbers(...nums: number[]) {
  // todo
}

joinNumbers(1, 2, 3)

// rest参数为元组
function joinTuple(...args: [boolean, number]) {
  // todo
}

joinTuple(false, 1)
joinTuple(true, 1)

// rest参数为元组
function joinTuple02(...args: [boolean, number?]) {
  // todo
}

joinTuple02(false)
joinTuple02(false, 2)

function multiply(n: number, ...m: number[]) {
  return m.map(x => n * x)
}

function f2(...args: [number, ...string[]]) {
  // todo
}

f2(1, '2', '3', '4')

function repeat(...[str, times]: [string, number]): string {
  return str.repeat(times)
}

// 等同于
// 等同于
function repeat2(str: string, times: number): string {
  return str.repeat(times)
}
